#include "GameOverNetworkEvent.h"
#include "GamePlayState.h"
#include <cstring>

GameOverNetworkEvent::GameOverNetworkEvent(const std::string& winner)
{
    message.header.code = NetworkEvent::SERVER_GAME_OVER;
    message.header.sizeOfData = sizeof(message.data);
    strncpy(message.data.winner, winner.c_str(), sizeof(message.data.winner));
}

GameOverNetworkEvent::GameOverNetworkEvent(const Header& header, const Data& data)
{
    message.header = header;
    message.data = data;
}

GameOverNetworkEvent::~GameOverNetworkEvent()
{
}

void* GameOverNetworkEvent::getMessageBlob()
{
    return &message;
}

size_t GameOverNetworkEvent::getMessageBlobSize()
{
    return sizeof(message);
}

GameState* GameOverNetworkEvent::visitGamePlayState(GamePlayState* gamePlayState) const
{
    return gamePlayState->goToGameOverState(message.data.winner);
}
